import request from '@/axios'
import { SysRoleComponentDetailVo, SysRoleComponentEditQo, SysRoleComponentListVo, SysRoleComponentSearchQo } from './types'
import { BaseDeleteQo } from '@/base/api/BaseQo'
import { KeyLabelValueVo } from '@/base/api/KeyLabelValueVo'

export const sysRoleComponentPageApi = (data: SysRoleComponentSearchQo): Promise<IResponse<Array<SysRoleComponentListVo>>> => {
  return request.post({ url: '/sysRoleComponent/page.adw', data })
}

export const sysRoleComponentDetailApi = (id: number): Promise<IResponse<SysRoleComponentDetailVo>> => {
  const data = { id }
  return request.post({
    url: '/sysRoleComponent/detail.adw',
    data
  })
}

export const sysRoleComponentAddApi = (data: SysRoleComponentEditQo): Promise<IResponse<number>> => {
  return request.post({ url: '/sysRoleComponent/add.adw', data })
}

export const sysRoleComponentUpdateApi = (data: SysRoleComponentEditQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysRoleComponent/update.adw', data })
}

export const sysRoleComponentDeleteApi = (data: BaseDeleteQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysRoleComponent/delete.adw', data })
}

export const sysRoleComponentSaveRoleRelApi= (data: SysRoleComponentEditQo): Promise<IResponse<number>> => {
  return request.post({ url: '/sysRoleComponent/saveRoleRel.adw', data })
}

// [[ OnflowGenerator Range (- selectFunctions -) Start ]]
export const selectSysRoleComponentRoleIdListApi = (
  data: SysRoleComponentSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysRoleComponent/selectRoleIdList.adw', data })
}
export const selectSysRoleComponentComponentIdListApi = (
  data: SysRoleComponentSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysRoleComponent/selectComponentIdList.adw', data })
}
export const selectSysRoleComponentMenuIdListApi = (
  data: SysRoleComponentSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysRoleComponent/selectMenuIdList.adw', data })
}
// [[ OnflowGenerator Range (- selectFunctions -) End ]]
